package work.xkong.bo;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @PACKAGE_NAME: work.xkong.bo
 * @NAME: TimeComparison
 * @USER: NuanYang
 * @create: 2022/11/25 17:40
 */
@Service
@Slf4j
public class TimeComparison {

    public boolean timeConflictVs(String firstTime,String lastTime){
        String[] splitFirst = firstTime.split("-");
        String[] splitLast = lastTime.split("-");
        int first = Integer.parseInt(splitFirst[1]);
        int last = Integer.parseInt(splitLast[1]);

        if (!splitFirst[0].equals(splitLast[0])){
            return false;
        }

        if (last > first){
            if (first+Integer.parseInt(splitFirst[2]) > last) {
                log.info("冲突了...");
                return true;
            }
        }else {
            if (last+Integer.parseInt(splitLast[2]) > first) {
                log.info("冲突了...");
                return true;
            }
        }

        return false;
    }
}
